package com.jpcc.vw.onlineRadio.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.RemoteException;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cns.android.atmospherelamp.AtmosphereLampManager;
import com.jpcc.vw.onlineRadio.R;
import com.jpcc.vw.onlineRadio.constants.Constants;
import com.jpcc.vw.onlineRadio.model.IRadio;
import com.jpcc.vw.onlineRadio.model.bean.BaseBean;
import com.jpcc.vw.onlineRadio.model.bean.VIPInfoBean;
import com.jpcc.vw.onlineRadio.model.impl.RadioImpl;
import com.jpcc.vw.onlineRadio.utils.CommonSubscriber;
import com.jpcc.vw.onlineRadio.utils.ToastUtils;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DiscoverActivity extends com.jpcc.vw.onlineRadio.base.BaseActivity {

    @BindView(R.id.layout_back)
    RelativeLayout layout_back;
    @BindView(R.id.layout_search)
    RelativeLayout layout_search;
    @BindView(R.id.layout_top_list)
    RelativeLayout layout_top_list;//每日推荐
    @BindView(R.id.layout_suggestion_list)
    RelativeLayout layout_suggestion_list;//专属推荐
    @BindView(R.id.layout_scategory_list)
    RelativeLayout layout_scategory_list;
    @BindView(R.id.tv_title)
    TextView tv_title;
    @BindView(R.id.layout_best_collection)
    RelativeLayout layout_best_collection;
    @BindView(R.id.layout_vip)
    RelativeLayout layout_vip;
    @BindView(R.id.imv_top_bottom_line)
    ImageView imv_top_bottom_line;
    @BindView(R.id.imv_new_search)
    ImageView imv_new_search;
    private IRadio radioModel;

    @Override
    public int getLayoutId() {
        return R.layout.activity_album_discover;
    }

    @Override
    public void setupView() {
        ButterKnife.bind(this);
        layout_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DiscoverActivity.this.finish();
            }
        });
        imv_new_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_search=new Intent(DiscoverActivity.this, SearchActivity.class);
                startActivity(intent_search);
            }
        });
        layout_top_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent_suggestion=new Intent(DiscoverActivity.this,DailyRecommendationActivity.class);
//                //每日推荐
//                intent_suggestion.putExtra("KEY_TYPE",0);
//                startActivity(intent_suggestion);
                Intent intent=new Intent(DiscoverActivity.this, TopListRanksActivity.class);
                startActivity(intent);
            }
        });
        layout_suggestion_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_suggestion=new Intent(DiscoverActivity.this,DailyRecommendationActivity.class);
                //专属推荐推荐
                intent_suggestion.putExtra("KEY_TYPE",1);
                startActivity(intent_suggestion);
            }
        });
        layout_scategory_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_scategory=new Intent(DiscoverActivity.this,AlbumCategoryActivity.class);
                startActivity(intent_scategory);
            }
        });
        tv_title.setText(getResources().getString(R.string.string_11));
        layout_best_collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_scategory=new Intent(DiscoverActivity.this,BestCollectionActivity.class);
                startActivity(intent_scategory);
            }
        });
        layout_vip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_scategory=new Intent(DiscoverActivity.this,VIPRecommendationActivity.class);
                startActivity(intent_scategory);
            }
        });
    }

    @Override
    public void setupData() {
        if (Constants.isRelease) {
            try {
                boolean atmosphereStatus = AtmosphereLampManager.getInstance(this).isHmiAtmosphereLampOn();
                String color = AtmosphereLampManager.getInstance(this).getHmiAtmosphereLampColor();
                doAtmosphere(atmosphereStatus, color);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void doAtmosphere(boolean rgbOn, String color) {
        Logger.i("doAtmosphere" + "rgbOn-->" + rgbOn);
        Logger.i("doAtmosphere" + "color-->" + color);
        if (rgbOn) {
            if (TextUtils.isEmpty(color)) {
                imv_top_bottom_line.setColorFilter(Color.TRANSPARENT);
            } else {
                imv_top_bottom_line.setColorFilter(Color.parseColor(color));
            }
        } else {
            imv_top_bottom_line.setColorFilter(Color.TRANSPARENT);
        }
    }
}
